package logic

import (
	"context"
	"fmt"
	"product/model/mysql"

	"product/productrpc/internal/svc"
	"product/productrpc/productrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type RatesListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRatesListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RatesListLogic {
	return &RatesListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 评论列表
func (l *RatesListLogic) RatesList(in *productrpc.RatesListRequest) (*productrpc.RatesListResponse, error) {
	// todo: add your logic here and delete this line
	var rates []mysql.Rates
	mysql.DB.Debug().Find(&rates)
	var productlists []*productrpc.RatesList
	for _, i2 := range rates {
		list := productrpc.RatesList{
			UserId:    i2.UserId,
			ProductId: i2.ProductId,
			Content:   i2.Content,
		}
		productlists = append(productlists, &list)
	}
	fmt.Println(productlists)
	return &productrpc.RatesListResponse{
		List: productlists,
	}, nil
}
